function [HE0, A0] = prepareLKAMKC(Ks, flag)
if iscell(Ks)
    Ks = cell2TriMat(Ks);
end

if ~exist('flag','var')
    flag = 1;
end
[nSmp,~,nKernel] = size(Ks);
gamma3 = ones(nKernel,1)/nKernel;
KC3 = sumKbeta(Ks,gamma3);

if flag == 1
    %******************************
    % Default setting
    %******************************
    %Calculate Neighborhood of each sample
    k = 5;
    NSt = genarateNeighborhood(KC3, k); %% tau*num
    A0 = zeros(nSmp);
    for i =1:nSmp
        A0(NSt(:,i),NSt(:,i)) = A0(NSt(:,i),NSt(:,i))+1;
    end
    %%%%%%%%%%%%%%%%%%%
    HE0 = calHessian(Ks,NSt,0);
else
    %******************************
    % Prof. Xinwang Liu' setting, the Local structure is averaged over
    % different neighborhood size
    %******************************
    tauset6 = [0.1:0.1:1];
    A0 = zeros(nSmp);
    HE0 = zeros(nKernel);
    for it =1:length(tauset6)
        %Calculate Neighborhood of each sample
        NSt = genarateNeighborhood(KC3,round(tauset6(it)*nSmp));%% tau*num
        A0t = zeros(nSmp);
        for i =1:nSmp
            A0t(NSt(:,i),NSt(:,i)) = A0t(NSt(:,i),NSt(:,i))+1;
        end
        A0 = A0 + (1/length(tauset6))*A0t;
        %%%%%%%%%%%%%%%%%%%
        HE0t = calHessian(Ks,NSt,0);
        HE0 = HE0 + (1/length(tauset6))*HE0t;
    end
end

end